home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 January: Mac OS SDK / Dev.CD Jan 98 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Universal / Interfaces / PInterfaces / SCSI.p < prev    next >
Encoding:
Text File  |  1997-08-12  |  50.1 KB  |  1,021 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        SCSI.p
  3.  
  4.      Contains:    SCSI Family Interfaces.
  5.  
  6.      Version:    Technology:    SCSI 4.3
  7.                  Release:    Universal Interfaces 3.0.1
  8.  
  9.      Copyright:    © 1986-1997 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:        Please include the the file and version information (from above) with
  12.                  the problem description.  Developers belonging to one of the Apple
  13.                  developer programs can submit bug reports to:
  14.  
  15.                      devsupport@apple.com
  16.  
  17. }
  18. {$IFC UNDEFINED UsingIncludes}
  19. {$SETC UsingIncludes := 0}
  20. {$ENDC}
  21.  
  22. {$IFC NOT UsingIncludes}
  23.  UNIT SCSI;
  24.  INTERFACE
  25. {$ENDC}
  26.  
  27. {$IFC UNDEFINED __SCSI__}
  28. {$SETC __SCSI__ := 1}
  29.  
  30. {$I+}
  31. {$SETC SCSIIncludes := UsingIncludes}
  32. {$SETC UsingIncludes := 1}
  33.  
  34. {$IFC UNDEFINED __TYPES__}
  35. {$I Types.p}
  36. {$ENDC}
  37. {$IFC UNDEFINED __MIXEDMODE__}
  38. {$I MixedMode.p}
  39. {$ENDC}
  40.  
  41.  
  42. {$PUSH}
  43. {$ALIGN MAC68K}
  44. {$LibExport+}
  45.  
  46. { SCSI Manager errors. These are generated by Inside Mac IV calls only. }
  47.  
  48. CONST
  49.     scCommErr                    = 2;                            {  communications error, operation timeout  }
  50.     scArbNBErr                    = 3;                            {  arbitration timeout waiting for not BSY  }
  51.     scBadParmsErr                = 4;                            {  bad parameter or TIB opcode  }
  52.     scPhaseErr                    = 5;                            {  SCSI bus not in correct phase for attempted operation  }
  53.     scCompareErr                = 6;                            {  data compare error  }
  54.     scMgrBusyErr                = 7;                            {  SCSI Manager busy   }
  55.     scSequenceErr                = 8;                            {  attempted operation is out of sequence  }
  56.     scBusTOErr                    = 9;                            {  CPU bus timeout  }
  57.     scComplPhaseErr                = 10;                            {  SCSI bus wasn't in Status phase  }
  58.  
  59. { TIB opcodes }
  60.     scInc                        = 1;
  61.     scNoInc                        = 2;
  62.     scAdd                        = 3;
  63.     scMove                        = 4;
  64.     scLoop                        = 5;
  65.     scNop                        = 6;
  66.     scStop                        = 7;
  67.     scComp                        = 8;
  68.  
  69. { Signatures }
  70.     sbSIGWord                    = $4552;                        {  signature word for Block 0 ('ER')  }
  71.     sbMac                        = 1;                            {  system type for Mac  }
  72.     pMapSIG                        = $504D;                        {  partition map signature ('PM')  }
  73.     pdSigWord                    = $5453;
  74.  
  75.     oldPMSigWord                = $5453;
  76.     newPMSigWord                = $504D;
  77.  
  78. { Driver Descriptor Map }
  79.  
  80. TYPE
  81.     Block0Ptr = ^Block0;
  82.     Block0 = PACKED RECORD
  83.         sbSig:                    INTEGER;                                {  unique value for SCSI block 0  }
  84.         sbBlkSize:                INTEGER;                                {  block size of device  }
  85.         sbBlkCount:                LONGINT;                                {  number of blocks on device  }
  86.         sbDevType:                INTEGER;                                {  device type  }
  87.         sbDevId:                INTEGER;                                {  device id  }
  88.         sbData:                    LONGINT;                                {  not used  }
  89.         sbDrvrCount:            INTEGER;                                {  driver descriptor count  }
  90.         ddBlock:                LONGINT;                                {  1st driver's starting block  }
  91.         ddSize:                    INTEGER;                                {  size of 1st driver (512-byte blks)  }
  92.         ddType:                    INTEGER;                                {  system type (1 for Mac+)  }
  93.         ddPad:                    ARRAY [0..242] OF INTEGER;                {  ARRAY[0..242] OF INTEGER; not used  }
  94.     END;
  95.  
  96. { Driver descriptor }
  97.     DDMapPtr = ^DDMap;
  98.     DDMap = RECORD
  99.         ddBlock:                LONGINT;                                {  1st driver's starting block  }
  100.         ddSize:                    INTEGER;                                {  size of 1st driver (512-byte blks)  }
  101.         ddType:                    INTEGER;                                {  system type (1 for Mac+)  }
  102.     END;
  103.  
  104. { Partition Map Entry }
  105.     PartitionPtr = ^Partition;
  106.     Partition = PACKED RECORD
  107.         pmSig:                    INTEGER;                                {  unique value for map entry blk  }
  108.         pmSigPad:                INTEGER;                                {  currently unused  }
  109.         pmMapBlkCnt:            LONGINT;                                {  # of blks in partition map  }
  110.         pmPyPartStart:            LONGINT;                                {  physical start blk of partition  }
  111.         pmPartBlkCnt:            LONGINT;                                {  # of blks in this partition  }
  112.         pmPartName:                PACKED ARRAY [0..31] OF UInt8;            {  ASCII partition name  }
  113.         pmParType:                PACKED ARRAY [0..31] OF UInt8;            {  ASCII partition type  }
  114.         pmLgDataStart:            LONGINT;                                {  log. # of partition's 1st data blk  }
  115.         pmDataCnt:                LONGINT;                                {  # of blks in partition's data area  }
  116.         pmPartStatus:            LONGINT;                                {  bit field for partition status  }
  117.         pmLgBootStart:            LONGINT;                                {  log. blk of partition's boot code  }
  118.         pmBootSize:                LONGINT;                                {  number of bytes in boot code  }
  119.         pmBootAddr:                LONGINT;                                {  memory load address of boot code  }
  120.         pmBootAddr2:            LONGINT;                                {  currently unused  }
  121.         pmBootEntry:            LONGINT;                                {  entry point of boot code  }
  122.         pmBootEntry2:            LONGINT;                                {  currently unused  }
  123.         pmBootCksum:            LONGINT;                                {  checksum of boot code  }
  124.         pmProcessor:            PACKED ARRAY [0..15] OF UInt8;            {  ASCII for the processor type  }
  125.         pmPad:                    ARRAY [0..187] OF INTEGER;                {  ARRAY[0..187] OF INTEGER; not used  }
  126.     END;
  127.  
  128. { TIB instruction }
  129.     SCSIInstrPtr = ^SCSIInstr;
  130.     SCSIInstr = RECORD
  131.         scOpcode:                INTEGER;
  132.         scParam1:                LONGINT;
  133.         scParam2:                LONGINT;
  134.     END;
  135.  
  136. { SCSI Phases (used by SIMs to support the Original SCSI Manager }
  137.  
  138. CONST
  139.     kDataOutPhase                = 0;                            {  Encoded MSG, C/D, I/O bits  }
  140.     kDataInPhase                = 1;
  141.     kCommandPhase                = 2;
  142.     kStatusPhase                = 3;
  143.     kPhaseIllegal0                = 4;
  144.     kPhaseIllegal1                = 5;
  145.     kMessageOutPhase            = 6;
  146.     kMessageInPhase                = 7;
  147.     kBusFreePhase                = 8;                            {  Additional Phases  }
  148.     kArbitratePhase                = 9;
  149.     kSelectPhase                = 10;
  150.     kMessageInPhaseNACK            = 11;                            {  Message In Phase with ACK hanging on the bus  }
  151.  
  152.  
  153. FUNCTION SCSIReset: OSErr;
  154.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  155.     INLINE $4267, $A815;
  156.     {$ENDC}
  157. FUNCTION SCSIGet: OSErr;
  158.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  159.     INLINE $3F3C, $0001, $A815;
  160.     {$ENDC}
  161. FUNCTION SCSISelect(targetID: INTEGER): OSErr;
  162.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  163.     INLINE $3F3C, $0002, $A815;
  164.     {$ENDC}
  165. FUNCTION SCSICmd(buffer: Ptr; count: INTEGER): OSErr;
  166.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  167.     INLINE $3F3C, $0003, $A815;
  168.     {$ENDC}
  169. FUNCTION SCSIRead(tibPtr: Ptr): OSErr;
  170.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  171.     INLINE $3F3C, $0005, $A815;
  172.     {$ENDC}
  173. FUNCTION SCSIRBlind(tibPtr: Ptr): OSErr;
  174.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  175.     INLINE $3F3C, $0008, $A815;
  176.     {$ENDC}
  177. FUNCTION SCSIWrite(tibPtr: Ptr): OSErr;
  178.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  179.     INLINE $3F3C, $0006, $A815;
  180.     {$ENDC}
  181. FUNCTION SCSIWBlind(tibPtr: Ptr): OSErr;
  182.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  183.     INLINE $3F3C, $0009, $A815;
  184.     {$ENDC}
  185. FUNCTION SCSIComplete(VAR stat: INTEGER; VAR message: INTEGER; wait: LONGINT): OSErr;
  186.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  187.     INLINE $3F3C, $0004, $A815;
  188.     {$ENDC}
  189. FUNCTION SCSIStat: INTEGER;
  190.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  191.     INLINE $3F3C, $000A, $A815;
  192.     {$ENDC}
  193. FUNCTION SCSISelAtn(targetID: INTEGER): OSErr;
  194.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  195.     INLINE $3F3C, $000B, $A815;
  196.     {$ENDC}
  197. FUNCTION SCSIMsgIn(VAR message: INTEGER): OSErr;
  198.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  199.     INLINE $3F3C, $000C, $A815;
  200.     {$ENDC}
  201. FUNCTION SCSIMsgOut(message: INTEGER): OSErr;
  202.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  203.     INLINE $3F3C, $000D, $A815;
  204.     {$ENDC}
  205.  
  206.  
  207. CONST
  208.     scsiVERSION                    = 43;
  209.  
  210.  
  211. {
  212.  * SCSI Callback Procedure Prototypes. Several of these are only callable
  213.  * from SCSI Manager 4.3 SIM and XPT contexts. 
  214.  }
  215.  
  216. TYPE
  217.     AENCallbackProcPtr = ProcPtr;  { PROCEDURE AENCallback; C; }
  218.  
  219.     SIMInitProcPtr = ProcPtr;  { FUNCTION SIMInit(SIMinfoPtr: Ptr): OSErr; C; }
  220.  
  221.     SIMActionProcPtr = ProcPtr;  { PROCEDURE SIMAction(scsiPB: UNIV Ptr; SIMGlobals: Ptr); C; }
  222.  
  223.     SCSIProcPtr = ProcPtr;  { PROCEDURE SCSI; C; }
  224.  
  225.     SCSIMakeCallbackProcPtr = ProcPtr;  { PROCEDURE SCSIMakeCallback(scsiPB: UNIV Ptr); C; }
  226.  
  227. { SCSIInterruptPollProcPtr is obsolete (use SCSIInterruptProcPtr) but still here for compatibility }
  228.     SCSIInterruptPollProcPtr = ProcPtr;  { FUNCTION SCSIInterruptPoll(SIMGlobals: Ptr): LONGINT; C; }
  229.  
  230.     SCSIInterruptProcPtr = ProcPtr;  { FUNCTION SCSIInterrupt(SIMGlobals: Ptr): LONGINT; C; }
  231.  
  232.     AENCallbackUPP = UniversalProcPtr;
  233.     SIMInitUPP = UniversalProcPtr;
  234.     SIMActionUPP = UniversalProcPtr;
  235.     SCSIUPP = UniversalProcPtr;
  236.     SCSIMakeCallbackUPP = UniversalProcPtr;
  237.     SCSIInterruptPollUPP = UniversalProcPtr;
  238.     SCSIInterruptUPP = UniversalProcPtr;
  239.     SCSICallbackProcPtr = ProcPtr;  { PROCEDURE SCSICallback(scsiPB: UNIV Ptr); }
  240.  
  241.     SCSICallbackUPP = UniversalProcPtr;
  242.  
  243. CONST
  244.     uppAENCallbackProcInfo = $00000001;
  245.     uppSIMInitProcInfo = $000000E1;
  246.     uppSIMActionProcInfo = $000003C1;
  247.     uppSCSIProcInfo = $00000001;
  248.     uppSCSIMakeCallbackProcInfo = $000000C1;
  249.     uppSCSIInterruptPollProcInfo = $000000F1;
  250.     uppSCSIInterruptProcInfo = $000000F1;
  251.     uppSCSICallbackProcInfo = $000000C0;
  252.  
  253. FUNCTION NewAENCallbackProc(userRoutine: AENCallbackProcPtr): AENCallbackUPP;
  254.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  255.     INLINE $2E9F;
  256.     {$ENDC}
  257.  
  258. FUNCTION NewSIMInitProc(userRoutine: SIMInitProcPtr): SIMInitUPP;
  259.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  260.     INLINE $2E9F;
  261.     {$ENDC}
  262.  
  263. FUNCTION NewSIMActionProc(userRoutine: SIMActionProcPtr): SIMActionUPP;
  264.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  265.     INLINE $2E9F;
  266.     {$ENDC}
  267.  
  268. FUNCTION NewSCSIProc(userRoutine: SCSIProcPtr): SCSIUPP;
  269.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  270.     INLINE $2E9F;
  271.     {$ENDC}
  272.  
  273. FUNCTION NewSCSIMakeCallbackProc(userRoutine: SCSIMakeCallbackProcPtr): SCSIMakeCallbackUPP;
  274.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  275.     INLINE $2E9F;
  276.     {$ENDC}
  277.  
  278. FUNCTION NewSCSIInterruptPollProc(userRoutine: SCSIInterruptPollProcPtr): SCSIInterruptPollUPP;
  279.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  280.     INLINE $2E9F;
  281.     {$ENDC}
  282.  
  283. FUNCTION NewSCSIInterruptProc(userRoutine: SCSIInterruptProcPtr): SCSIInterruptUPP;
  284.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  285.     INLINE $2E9F;
  286.     {$ENDC}
  287.  
  288. FUNCTION NewSCSICallbackProc(userRoutine: SCSICallbackProcPtr): SCSICallbackUPP;
  289.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  290.     INLINE $2E9F;
  291.     {$ENDC}
  292.  
  293. PROCEDURE CallAENCallbackProc(userRoutine: AENCallbackUPP);
  294.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  295.     {To be implemented:  Glue to move parameters into registers.}
  296.     {$ENDC}
  297.  
  298. FUNCTION CallSIMInitProc(SIMinfoPtr: Ptr; userRoutine: SIMInitUPP): OSErr;
  299.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  300.     {To be implemented:  Glue to move parameters into registers.}
  301.     {$ENDC}
  302.  
  303. PROCEDURE CallSIMActionProc(scsiPB: UNIV Ptr; SIMGlobals: Ptr; userRoutine: SIMActionUPP);
  304.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  305.     {To be implemented:  Glue to move parameters into registers.}
  306.     {$ENDC}
  307.  
  308. PROCEDURE CallSCSIProc(userRoutine: SCSIUPP);
  309.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  310.     {To be implemented:  Glue to move parameters into registers.}
  311.     {$ENDC}
  312.  
  313. PROCEDURE CallSCSIMakeCallbackProc(scsiPB: UNIV Ptr; userRoutine: SCSIMakeCallbackUPP);
  314.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  315.     {To be implemented:  Glue to move parameters into registers.}
  316.     {$ENDC}
  317.  
  318. FUNCTION CallSCSIInterruptPollProc(SIMGlobals: Ptr; userRoutine: SCSIInterruptPollUPP): LONGINT;
  319.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  320.     {To be implemented:  Glue to move parameters into registers.}
  321.     {$ENDC}
  322.  
  323. FUNCTION CallSCSIInterruptProc(SIMGlobals: Ptr; userRoutine: SCSIInterruptUPP): LONGINT;
  324.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  325.     {To be implemented:  Glue to move parameters into registers.}
  326.     {$ENDC}
  327.  
  328. PROCEDURE CallSCSICallbackProc(scsiPB: UNIV Ptr; userRoutine: SCSICallbackUPP);
  329.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  330.     INLINE $205F, $4E90;
  331.     {$ENDC}
  332. { SCSI Manager 4.3 function codes }
  333.  
  334. CONST
  335.     SCSINop                        = $00;                            {  Execute nothing                                          }
  336.     SCSIExecIO                    = $01;                            {  Execute the specified IO                              }
  337.     SCSIBusInquiry                = $03;                            {  Get parameters for entire path of HBAs                  }
  338.     SCSIReleaseQ                = $04;                            {  Release the frozen SIM queue for particular LUN          }
  339.     SCSIAbortCommand            = $10;                            {  Abort the selected Control Block                       }
  340.     SCSIResetBus                = $11;                            {  Reset the SCSI bus                                       }
  341.     SCSIResetDevice                = $12;                            {  Reset the SCSI device                                   }
  342.     SCSITerminateIO                = $13;                            {  Terminate any pending IO                               }
  343.     SCSIGetVirtualIDInfo        = $80;                            {  Find out which bus old ID is on                          }
  344.     SCSILoadDriver                = $82;                            {  Load a driver for a device ident                      }
  345.     SCSIOldCall                    = $84;                            {  XPT->SIM private call for old-API                      }
  346.     SCSICreateRefNumXref        = $85;                            {  Register a DeviceIdent to drvr RefNum xref              }
  347.     SCSILookupRefNumXref        = $86;                            {  Get DeviceIdent to drvr RefNum xref                      }
  348.     SCSIRemoveRefNumXref        = $87;                            {  Remove a DeviceIdent to drvr RefNum xref              }
  349.     SCSIRegisterWithNewXPT        = $88;                            {  XPT has changed - SIM needs to re-register itself      }
  350.     vendorUnique                = $C0;                            {  0xC0 thru 0xFF  }
  351.  
  352.  
  353. { Allocation length defines for some of the fields }
  354.     handshakeDataLength            = 8;                            {  Handshake data length  }
  355.     maxCDBLength                = 16;                            {  Space for the CDB bytes/pointer  }
  356.     vendorIDLength                = 16;                            {  ASCII string len for Vendor ID   }
  357.  
  358. { Define DeviceIdent structure }
  359.  
  360. TYPE
  361.     DeviceIdentPtr = ^DeviceIdent;
  362.     DeviceIdent = PACKED RECORD
  363.         diReserved:                UInt8;                                    {  reserved                  }
  364.         bus:                    UInt8;                                    {  SCSI - Bus Number         }
  365.         targetID:                UInt8;                                    {  SCSI - Target SCSI ID     }
  366.         LUN:                    UInt8;                                    {  SCSI - LUN                   }
  367.     END;
  368.  
  369. { Command Descriptor Block structure }
  370.     CDBPtr = ^CDB;
  371.     CDB = RECORD
  372.         CASE INTEGER OF
  373.         0: (
  374.             cdbPtr:                BytePtr;                                {  pointer to the CDB, or  }
  375.             );
  376.         1: (
  377.             cdbBytes:            PACKED ARRAY [0..15] OF UInt8;            {  the actual CDB to send  }
  378.             );
  379.     END;
  380.  
  381. { Scatter/gather list element (Deprecated for MacOS8) }
  382.     SGRecordPtr = ^SGRecord;
  383.     SGRecord = RECORD
  384.         SGAddr:                    Ptr;
  385.         SGCount:                UInt32;
  386.     END;
  387.  
  388.     SCSIHdrPtr = ^SCSIHdr;
  389.     SCSIHdr = RECORD
  390.         qLink:                    SCSIHdrPtr;                                {  (internal use, must be nil on entry)     }
  391.         scsiReserved1:            INTEGER;                                {  ->     reserved for input                 }
  392.         scsiPBLength:            UInt16;                                    {  -> Length of the entire PB             }
  393.         scsiFunctionCode:        SInt8;                                    {  -> function selector                  }
  394.         scsiReserved2:            SInt8;                                    {  <-     reserved for output                 }
  395.         scsiResult:                OSErr;                                    {  <- Returned result                      }
  396.         scsiDevice:                DeviceIdent;                            {  -> Device Identifier (bus+target+lun) }
  397.         scsiCompletion:            SCSICallbackUPP;                        {  -> Callback on completion function       }
  398.         scsiFlags:                UInt32;                                    {  -> assorted flags                     }
  399.         scsiDriverStorage:        BytePtr;                                {  <> Ptr for driver private use         }
  400.         scsiXPTprivate:            Ptr;                                    {  private field for use in XPT             }
  401.         scsiReserved3:            LONGINT;                                {  reserved                                 }
  402.     END;
  403.  
  404.     SCSI_PBPtr = ^SCSI_PB;
  405.     SCSI_PB = RECORD
  406.         qLink:                    SCSIHdrPtr;                                {  (internal use, must be nil on entry)     }
  407.         scsiReserved1:            INTEGER;                                {  ->     reserved for input                 }
  408.         scsiPBLength:            UInt16;                                    {  -> Length of the entire PB             }
  409.         scsiFunctionCode:        SInt8;                                    {  -> function selector                  }
  410.         scsiReserved2:            SInt8;                                    {  <-     reserved for output                 }
  411.         scsiResult:                OSErr;                                    {  <- Returned result                      }
  412.         scsiDevice:                DeviceIdent;                            {  -> Device Identifier (bus+target+lun) }
  413.         scsiCompletion:            SCSICallbackUPP;                        {  -> Callback on completion function       }
  414.         scsiFlags:                UInt32;                                    {  -> assorted flags                     }
  415.         scsiDriverStorage:        BytePtr;                                {  <> Ptr for driver private use         }
  416.         scsiXPTprivate:            Ptr;                                    {  private field for use in XPT             }
  417.         scsiReserved3:            LONGINT;                                {  reserved                                 }
  418.     END;
  419.  
  420.     SCSI_IOPtr = ^SCSI_IO;
  421.     SCSI_IO = RECORD
  422.         qLink:                    SCSIHdrPtr;                                {  (internal use, must be nil on entry)     }
  423.         scsiReserved1:            INTEGER;                                {  ->     reserved for input                 }
  424.         scsiPBLength:            UInt16;                                    {  -> Length of the entire PB             }
  425.         scsiFunctionCode:        SInt8;                                    {  -> function selector                  }
  426.         scsiReserved2:            SInt8;                                    {  <-     reserved for output                 }
  427.         scsiResult:                OSErr;                                    {  <- Returned result                      }
  428.         scsiDevice:                DeviceIdent;                            {  -> Device Identifier (bus+target+lun) }
  429.         scsiCompletion:            SCSICallbackUPP;                        {  -> Callback on completion function       }
  430.         scsiFlags:                UInt32;                                    {  -> assorted flags                     }
  431.         scsiDriverStorage:        BytePtr;                                {  <> Ptr for driver private use         }
  432.         scsiXPTprivate:            Ptr;                                    {  private field for use in XPT             }
  433.         scsiReserved3:            LONGINT;                                {  reserved                                 }
  434.         scsiResultFlags:        UInt16;                                    {  <- Flags which modify the scsiResult field         }
  435.         scsiReserved3pt5:        UInt16;                                    {  -> Reserved                                         }
  436.         scsiDataPtr:            BytePtr;                                {  -> Pointer to the data buffer or the S/G list       }
  437.         scsiDataLength:            UInt32;                                    {  -> Data transfer length                             }
  438.         scsiSensePtr:            BytePtr;                                {  -> Ptr to autosense data buffer                   }
  439.         scsiSenseLength:        SInt8;                                    {  -> size of the autosense buffer                      }
  440.         scsiCDBLength:            SInt8;                                    {  -> Number of bytes for the CDB                       }
  441.         scsiSGListCount:        UInt16;                                    {  -> num of scatter gather list entries               }
  442.         scsiReserved4:            UInt32;                                    {  <-     reserved for output                             }
  443.         scsiSCSIstatus:            SInt8;                                    {  <- Returned scsi device status                       }
  444.         scsiSenseResidual:        SInt8;                                    {  <- Autosense residual length                       }
  445.         scsiReserved5:            UInt16;                                    {  <-     reserved for output                              }
  446.         scsiDataResidual:        LONGINT;                                {  <- Returned Transfer residual length               }
  447.         scsiCDB:                CDB;                                    {  -> Actual CDB or pointer to CDB                   }
  448.         scsiTimeout:            LONGINT;                                {  -> Timeout value (Time Mgr format) (CAM timeout)  }
  449.         scsiReserved5pt5:        BytePtr;                                {  -> Reserved                                         }
  450.         scsiReserved5pt6:        UInt16;                                    {  -> Reserved                                         }
  451.         scsiIOFlags:            UInt16;                                    {  -> additional I/O flags                                }
  452.         scsiTagAction:            SInt8;                                    {  -> What to do for tag queuing                        }
  453.         scsiReserved6:            SInt8;                                    {  ->     reserved for input                              }
  454.         scsiReserved7:            UInt16;                                    {  ->     reserved for input                              }
  455.         scsiSelectTimeout:        UInt16;                                    {  -> Select timeout value                              }
  456.         scsiDataType:            SInt8;                                    {  -> Data description type (i.e. buffer, TIB, S/G)     }
  457.         scsiTransferType:        SInt8;                                    {  -> Transfer type (i.e. Blind vs Polled)              }
  458.         scsiReserved8:            UInt32;                                    {  ->     reserved for input                              }
  459.         scsiReserved9:            UInt32;                                    {  ->     reserved for input                              }
  460.         scsiHandshake:            ARRAY [0..7] OF UInt16;                    {  -> handshaking points (null term'd)     }
  461.         scsiReserved10:            UInt32;                                    {  ->     reserved for input                              }
  462.         scsiReserved11:            UInt32;                                    {  ->   reserved for input                             }
  463.         scsiCommandLink:        SCSI_IOPtr;                                {  -> Ptr to the next PB in linked cmd chain          }
  464.         scsiSIMpublics:            PACKED ARRAY [0..7] OF UInt8;            {  ->     reserved for input to 3rd-party SIMs         }
  465.         scsiAppleReserved6:        PACKED ARRAY [0..7] OF UInt8;            {  ->    reserved for input                               }
  466.                                                                         {  XPT layer privates (for old-API emulation)  }
  467.         scsiCurrentPhase:        UInt16;                                    {  <- phase upon completing old call                   }
  468.         scsiSelector:            INTEGER;                                {  -> selector specified in old calls                   }
  469.         scsiOldCallResult:        OSErr;                                    {  <- result of old call                               }
  470.         scsiSCSImessage:        SInt8;                                    {  <- Returned scsi device message (for SCSIComplete) }
  471.         XPTprivateFlags:        SInt8;                                    {  <> various flags                                    }
  472.         XPTextras:                PACKED ARRAY [0..11] OF UInt8;            {                                                      }
  473.     END;
  474.  
  475.     SCSIExecIOPB                        = SCSI_IO;
  476.     SCSIExecIOPBPtr                     = ^SCSIExecIOPB;
  477. { Bus inquiry PB }
  478.     SCSIBusInquiryPBPtr = ^SCSIBusInquiryPB;
  479.     SCSIBusInquiryPB = RECORD
  480.         qLink:                    SCSIHdrPtr;                                {  (internal use, must be nil on entry)     }
  481.         scsiReserved1:            INTEGER;                                {  ->     reserved for input                 }
  482.         scsiPBLength:            UInt16;                                    {  -> Length of the entire PB             }
  483.         scsiFunctionCode:        SInt8;                                    {  -> function selector                  }
  484.         scsiReserved2:            SInt8;                                    {  <-     reserved for output                 }
  485.         scsiResult:                OSErr;                                    {  <- Returned result                      }
  486.         scsiDevice:                DeviceIdent;                            {  -> Device Identifier (bus+target+lun) }
  487.         scsiCompletion:            SCSICallbackUPP;                        {  -> Callback on completion function       }
  488.         scsiFlags:                UInt32;                                    {  -> assorted flags                     }
  489.         scsiDriverStorage:        BytePtr;                                {  <> Ptr for driver private use         }
  490.         scsiXPTprivate:            Ptr;                                    {  private field for use in XPT             }
  491.         scsiReserved3:            LONGINT;                                {  reserved                                 }
  492.         scsiEngineCount:        UInt16;                                    {  <- Number of engines on HBA                          }
  493.         scsiMaxTransferType:    UInt16;                                    {  <- Number of transfer types for this HBA             }
  494.         scsiDataTypes:            UInt32;                                    {  <- which data types are supported by this SIM      }
  495.         scsiIOpbSize:            UInt16;                                    {  <- Size of SCSI_IO PB for this SIM/HBA              }
  496.         scsiMaxIOpbSize:        UInt16;                                    {  <- Size of max SCSI_IO PB for all SIM/HBAs          }
  497.         scsiFeatureFlags:        UInt32;                                    {  <- Supported features flags field                  }
  498.         scsiVersionNumber:        SInt8;                                    {  <- Version number for the SIM/HBA                  }
  499.         scsiHBAInquiry:            SInt8;                                    {  <- Mimic of INQ byte 7 for the HBA                  }
  500.         scsiTargetModeFlags:    SInt8;                                    {  <- Flags for target mode support                  }
  501.         scsiScanFlags:            SInt8;                                    {  <- Scan related feature flags                      }
  502.         scsiSIMPrivatesPtr:        UInt32;                                    {  <- Ptr to SIM private data area                      }
  503.         scsiSIMPrivatesSize:    UInt32;                                    {  <- Size of SIM private data area                  }
  504.         scsiAsyncFlags:            UInt32;                                    {  <- Event cap. for Async Callback                  }
  505.         scsiHiBusID:            SInt8;                                    {  <- Highest path ID in the subsystem               }
  506.         scsiInitiatorID:        SInt8;                                    {  <- ID of the HBA on the SCSI bus                  }
  507.         scsiBIReserved0:        UInt16;                                    {                                                      }
  508.         scsiBIReserved1:        UInt32;                                    {  <-                                                   }
  509.         scsiFlagsSupported:        UInt32;                                    {  <- which scsiFlags are supported                  }
  510.         scsiIOFlagsSupported:    UInt16;                                    {  <- which scsiIOFlags are supported                  }
  511.         scsiWeirdStuff:            UInt16;                                    {  <-                                                  }
  512.         scsiMaxTarget:            UInt16;                                    {  <- maximum Target number supported                  }
  513.         scsiMaxLUN:                UInt16;                                    {  <- maximum Logical Unit number supported          }
  514.         scsiSIMVendor:            PACKED ARRAY [0..15] OF CHAR;            {  <- Vendor ID of SIM (or XPT if bus<FF)          }
  515.         scsiHBAVendor:            PACKED ARRAY [0..15] OF CHAR;            {  <- Vendor ID of the HBA                          }
  516.         scsiControllerFamily:    PACKED ARRAY [0..15] OF CHAR;            {  <- Family of SCSI Controller                  }
  517.         scsiControllerType:        PACKED ARRAY [0..15] OF CHAR;            {  <- Specific Model of SCSI Controller used      }
  518.         scsiXPTversion:            PACKED ARRAY [0..3] OF CHAR;            {  <- version number of XPT                          }
  519.         scsiSIMversion:            PACKED ARRAY [0..3] OF CHAR;            {  <- version number of SIM                          }
  520.         scsiHBAversion:            PACKED ARRAY [0..3] OF CHAR;            {  <- version number of HBA                          }
  521.         scsiHBAslotType:        SInt8;                                    {  <- type of "slot" that this HBA is in             }
  522.         scsiHBAslotNumber:        SInt8;                                    {  <- slot number of this HBA                          }
  523.         scsiSIMsRsrcID:            UInt16;                                    {  <- resource ID of this SIM                          }
  524.         scsiBIReserved3:        UInt16;                                    {  <-                                                  }
  525.         scsiAdditionalLength:    UInt16;                                    {  <- additional BusInquiry PB len                     }
  526.     END;
  527.  
  528. { Abort SIM Request PB }
  529.     SCSIAbortCommandPBPtr = ^SCSIAbortCommandPB;
  530.     SCSIAbortCommandPB = RECORD
  531.         qLink:                    SCSIHdrPtr;                                {  (internal use, must be nil on entry)     }
  532.         scsiReserved1:            INTEGER;                                {  ->     reserved for input                 }
  533.         scsiPBLength:            UInt16;                                    {  -> Length of the entire PB             }
  534.         scsiFunctionCode:        SInt8;                                    {  -> function selector                  }
  535.         scsiReserved2:            SInt8;                                    {  <-     reserved for output                 }
  536.         scsiResult:                OSErr;                                    {  <- Returned result                      }
  537.         scsiDevice:                DeviceIdent;                            {  -> Device Identifier (bus+target+lun) }
  538.         scsiCompletion:            SCSICallbackUPP;                        {  -> Callback on completion function       }
  539.         scsiFlags:                UInt32;                                    {  -> assorted flags                     }
  540.         scsiDriverStorage:        BytePtr;                                {  <> Ptr for driver private use         }
  541.         scsiXPTprivate:            Ptr;                                    {  private field for use in XPT             }
  542.         scsiReserved3:            LONGINT;                                {  reserved                                 }
  543.         scsiIOptr:                SCSI_IOPtr;                                {  Pointer to the PB to abort             }
  544.     END;
  545.  
  546. { Terminate I/O Process Request PB }
  547.     SCSITerminateIOPBPtr = ^SCSITerminateIOPB;
  548.     SCSITerminateIOPB = RECORD
  549.         qLink:                    SCSIHdrPtr;                                {  (internal use, must be nil on entry)     }
  550.         scsiReserved1:            INTEGER;                                {  ->     reserved for input                 }
  551.         scsiPBLength:            UInt16;                                    {  -> Length of the entire PB             }
  552.         scsiFunctionCode:        SInt8;                                    {  -> function selector                  }
  553.         scsiReserved2:            SInt8;                                    {  <-     reserved for output                 }
  554.         scsiResult:                OSErr;                                    {  <- Returned result                      }
  555.         scsiDevice:                DeviceIdent;                            {  -> Device Identifier (bus+target+lun) }
  556.         scsiCompletion:            SCSICallbackUPP;                        {  -> Callback on completion function       }
  557.         scsiFlags:                UInt32;                                    {  -> assorted flags                     }
  558.         scsiDriverStorage:        BytePtr;                                {  <> Ptr for driver private use         }
  559.         scsiXPTprivate:            Ptr;                                    {  private field for use in XPT             }
  560.         scsiReserved3:            LONGINT;                                {  reserved                                 }
  561.         scsiIOptr:                SCSI_IOPtr;                                {  Pointer to the PB to terminate          }
  562.     END;
  563.  
  564. { Reset SCSI Bus PB }
  565.     SCSIResetBusPBPtr = ^SCSIResetBusPB;
  566.     SCSIResetBusPB = RECORD
  567.         qLink:                    SCSIHdrPtr;                                {  (internal use, must be nil on entry)     }
  568.         scsiReserved1:            INTEGER;                                {  ->     reserved for input                 }
  569.         scsiPBLength:            UInt16;                                    {  -> Length of the entire PB             }
  570.         scsiFunctionCode:        SInt8;                                    {  -> function selector                  }
  571.         scsiReserved2:            SInt8;                                    {  <-     reserved for output                 }
  572.         scsiResult:                OSErr;                                    {  <- Returned result                      }
  573.         scsiDevice:                DeviceIdent;                            {  -> Device Identifier (bus+target+lun) }
  574.         scsiCompletion:            SCSICallbackUPP;                        {  -> Callback on completion function       }
  575.         scsiFlags:                UInt32;                                    {  -> assorted flags                     }
  576.         scsiDriverStorage:        BytePtr;                                {  <> Ptr for driver private use         }
  577.         scsiXPTprivate:            Ptr;                                    {  private field for use in XPT             }
  578.         scsiReserved3:            LONGINT;                                {  reserved                                 }
  579.     END;
  580.  
  581. { Reset SCSI Device PB }
  582.     SCSIResetDevicePBPtr = ^SCSIResetDevicePB;
  583.     SCSIResetDevicePB = RECORD
  584.         qLink:                    SCSIHdrPtr;                                {  (internal use, must be nil on entry)     }
  585.         scsiReserved1:            INTEGER;                                {  ->     reserved for input                 }
  586.         scsiPBLength:            UInt16;                                    {  -> Length of the entire PB             }
  587.         scsiFunctionCode:        SInt8;                                    {  -> function selector                  }
  588.         scsiReserved2:            SInt8;                                    {  <-     reserved for output                 }
  589.         scsiResult:                OSErr;                                    {  <- Returned result                      }
  590.         scsiDevice:                DeviceIdent;                            {  -> Device Identifier (bus+target+lun) }
  591.         scsiCompletion:            SCSICallbackUPP;                        {  -> Callback on completion function       }
  592.         scsiFlags:                UInt32;                                    {  -> assorted flags                     }
  593.         scsiDriverStorage:        BytePtr;                                {  <> Ptr for driver private use         }
  594.         scsiXPTprivate:            Ptr;                                    {  private field for use in XPT             }
  595.         scsiReserved3:            LONGINT;                                {  reserved                                 }
  596.     END;
  597.  
  598. { Release SIM Queue PB }
  599.     SCSIReleaseQPBPtr = ^SCSIReleaseQPB;
  600.     SCSIReleaseQPB = RECORD
  601.         qLink:                    SCSIHdrPtr;                                {  (internal use, must be nil on entry)     }
  602.         scsiReserved1:            INTEGER;                                {  ->     reserved for input                 }
  603.         scsiPBLength:            UInt16;                                    {  -> Length of the entire PB             }
  604.         scsiFunctionCode:        SInt8;                                    {  -> function selector                  }
  605.         scsiReserved2:            SInt8;                                    {  <-     reserved for output                 }
  606.         scsiResult:                OSErr;                                    {  <- Returned result                      }
  607.         scsiDevice:                DeviceIdent;                            {  -> Device Identifier (bus+target+lun) }
  608.         scsiCompletion:            SCSICallbackUPP;                        {  -> Callback on completion function       }
  609.         scsiFlags:                UInt32;                                    {  -> assorted flags                     }
  610.         scsiDriverStorage:        BytePtr;                                {  <> Ptr for driver private use         }
  611.         scsiXPTprivate:            Ptr;                                    {  private field for use in XPT             }
  612.         scsiReserved3:            LONGINT;                                {  reserved                                 }
  613.     END;
  614.  
  615. { SCSI Get Virtual ID Info PB }
  616.     SCSIGetVirtualIDInfoPBPtr = ^SCSIGetVirtualIDInfoPB;
  617.     SCSIGetVirtualIDInfoPB = RECORD
  618.         qLink:                    SCSIHdrPtr;                                {  (internal use, must be nil on entry)     }
  619.         scsiReserved1:            INTEGER;                                {  ->     reserved for input                 }
  620.         scsiPBLength:            UInt16;                                    {  -> Length of the entire PB             }
  621.         scsiFunctionCode:        SInt8;                                    {  -> function selector                  }
  622.         scsiReserved2:            SInt8;                                    {  <-     reserved for output                 }
  623.         scsiResult:                OSErr;                                    {  <- Returned result                      }
  624.         scsiDevice:                DeviceIdent;                            {  -> Device Identifier (bus+target+lun) }
  625.         scsiCompletion:            SCSICallbackUPP;                        {  -> Callback on completion function       }
  626.         scsiFlags:                UInt32;                                    {  -> assorted flags                     }
  627.         scsiDriverStorage:        Ptr;                                    {  <> Ptr for driver private use         }
  628.         scsiXPTprivate:            Ptr;                                    {  private field for use in XPT             }
  629.         scsiReserved3:            LONGINT;                                {  reserved                                 }
  630.         scsiOldCallID:            UInt16;                                    {  -> SCSI ID of device in question      }
  631.         scsiExists:                BOOLEAN;                                {  <- true if device exists              }
  632.         filler:                    SInt8;
  633.     END;
  634.  
  635. { Create/Lookup/Remove RefNum for Device PB }
  636.     SCSIDriverPBPtr = ^SCSIDriverPB;
  637.     SCSIDriverPB = RECORD
  638.         qLink:                    SCSIHdrPtr;                                {  (internal use, must be nil on entry)     }
  639.         scsiReserved1:            INTEGER;                                {  ->     reserved for input                 }
  640.         scsiPBLength:            UInt16;                                    {  -> Length of the entire PB             }
  641.         scsiFunctionCode:        SInt8;                                    {  -> function selector                  }
  642.         scsiReserved2:            SInt8;                                    {  <-     reserved for output                 }
  643.         scsiResult:                OSErr;                                    {  <- Returned result                      }
  644.         scsiDevice:                DeviceIdent;                            {  -> Device Identifier (bus+target+lun) }
  645.         scsiCompletion:            SCSICallbackUPP;                        {  -> Callback on completion function       }
  646.         scsiFlags:                UInt32;                                    {  -> assorted flags                     }
  647.         scsiDriverStorage:        Ptr;                                    {  <> Ptr for driver private use         }
  648.         scsiXPTprivate:            Ptr;                                    {  private field for use in XPT             }
  649.         scsiReserved3:            LONGINT;                                {  reserved                                 }
  650.         scsiDriver:                INTEGER;                                {  -> DriverRefNum, For SetDriver, <- For GetNextDriver  }
  651.         scsiDriverFlags:        UInt16;                                    {  <> Details of driver/device              }
  652.         scsiNextDevice:            DeviceIdent;                            {  <- DeviceIdent of the NEXT Item in the list   }
  653.     END;
  654.  
  655. { Load Driver PB }
  656.     SCSILoadDriverPBPtr = ^SCSILoadDriverPB;
  657.     SCSILoadDriverPB = RECORD
  658.         qLink:                    SCSIHdrPtr;                                {  (internal use, must be nil on entry)     }
  659.         scsiReserved1:            INTEGER;                                {  ->     reserved for input                 }
  660.         scsiPBLength:            UInt16;                                    {  -> Length of the entire PB             }
  661.         scsiFunctionCode:        SInt8;                                    {  -> function selector                  }
  662.         scsiReserved2:            SInt8;                                    {  <-     reserved for output                 }
  663.         scsiResult:                OSErr;                                    {  <- Returned result                      }
  664.         scsiDevice:                DeviceIdent;                            {  -> Device Identifier (bus+target+lun) }
  665.         scsiCompletion:            SCSICallbackUPP;                        {  -> Callback on completion function       }
  666.         scsiFlags:                UInt32;                                    {  -> assorted flags                     }
  667.         scsiDriverStorage:        Ptr;                                    {  <> Ptr for driver private use         }
  668.         scsiXPTprivate:            Ptr;                                    {  private field for use in XPT             }
  669.         scsiReserved3:            LONGINT;                                {  reserved                                 }
  670.         scsiLoadedRefNum:        INTEGER;                                {  <- SIM returns refnum of driver          }
  671.         scsiDiskLoadFailed:        BOOLEAN;                                {  -> if true, indicates call after failure to load  }
  672.         filler:                    SInt8;
  673.     END;
  674.  
  675.  
  676. { Defines for the scsiTransferType field }
  677.  
  678. CONST
  679.     scsiTransferBlind            = 0;
  680.     scsiTransferPolled            = 1;
  681.  
  682.     scsiErrorBase                = -7936;
  683.  
  684.     scsiRequestInProgress        = 1;                            {  1     = PB request is in progress              }
  685.                                                                 {  Execution failed  00-2F  }
  686.     scsiRequestAborted            = -7934;                        {  -7934 = PB request aborted by the host          }
  687.     scsiUnableToAbort            = -7933;                        {  -7933 = Unable to Abort PB request              }
  688.     scsiNonZeroStatus            = -7932;                        {  -7932 = PB request completed with an err      }
  689.     scsiUnused05                = -7931;                        {  -7931 =                                       }
  690.     scsiUnused06                = -7930;                        {  -7930 =                                       }
  691.     scsiUnused07                = -7929;                        {  -7929 =                                       }
  692.     scsiUnused08                = -7928;                        {  -7928 =                                       }
  693.     scsiUnableToTerminate        = -7927;                        {  -7927 = Unable to Terminate I/O PB req          }
  694.     scsiSelectTimeout            = -7926;                        {  -7926 = Target selection timeout              }
  695.     scsiCommandTimeout            = -7925;                        {  -7925 = Command timeout                       }
  696.     scsiIdentifyMessageRejected    = -7924;                        {  -7924 =                                       }
  697.     scsiMessageRejectReceived    = -7923;                        {  -7923 = Message reject received                  }
  698.     scsiSCSIBusReset            = -7922;                        {  -7922 = SCSI bus reset sent/received          }
  699.     scsiParityError                = -7921;                        {  -7921 = Uncorrectable parity error occured      }
  700.     scsiAutosenseFailed            = -7920;                        {  -7920 = Autosense: Request sense cmd fail      }
  701.     scsiUnused11                = -7919;                        {  -7919 =                                       }
  702.     scsiDataRunError            = -7918;                        {  -7918 = Data overrun/underrun error           }
  703.     scsiUnexpectedBusFree        = -7917;                        {  -7917 = Unexpected BUS free                      }
  704.     scsiSequenceFailed            = -7916;                        {  -7916 = Target bus phase sequence failure      }
  705.     scsiWrongDirection            = -7915;                        {  -7915 = Data phase was in wrong direction      }
  706.     scsiUnused16                = -7914;                        {  -7914 =                                       }
  707.     scsiBDRsent                    = -7913;                        {  -7913 = A SCSI BDR msg was sent to target      }
  708.     scsiTerminated                = -7912;                        {  -7912 = PB request terminated by the host      }
  709.     scsiNoNexus                    = -7911;                        {  -7911 = Nexus is not established              }
  710.     scsiCDBReceived                = -7910;                        {  -7910 = The SCSI CDB has been received          }
  711.                                                                 {  Couldn't begin execution  30-3F  }
  712.     scsiTooManyBuses            = -7888;                        {  -7888 = Register failed because we're full     }
  713.     scsiBusy                    = -7887;                        {  -7887 = SCSI subsystem is busy                  }
  714.     scsiProvideFail                = -7886;                        {  -7886 = Unable to provide requ. capability     }
  715.     scsiDeviceNotThere            = -7885;                        {  -7885 = SCSI device not installed/there       }
  716.     scsiNoHBA                    = -7884;                        {  -7884 = No HBA detected Error                  }
  717.     scsiDeviceConflict            = -7883;                        {  -7883 = sorry, max 1 refNum per DeviceIdent      }
  718.     scsiNoSuchXref                = -7882;                        {  -7882 = no such RefNum xref                      }
  719.     scsiQLinkInvalid            = -7881;                        {  -7881 = pre-linked PBs not supported             }
  720.                                                                 {    (The QLink field was nonzero)                 }
  721.                                                                 {  Parameter errors  40-7F  }
  722.     scsiPBLengthError            = -7872;                        {  -7872 = (scsiPBLength is insuf'ct/invalid      }
  723.     scsiFunctionNotAvailable    = -7871;                        {  -7871 = The requ. func is not available       }
  724.     scsiRequestInvalid            = -7870;                        {  -7870 = PB request is invalid                  }
  725.     scsiBusInvalid                = -7869;                        {  -7869 = Bus ID supplied is invalid               }
  726.     scsiTIDInvalid                = -7868;                        {  -7868 = Target ID supplied is invalid          }
  727.     scsiLUNInvalid                = -7867;                        {  -7867 = LUN supplied is invalid               }
  728.     scsiIDInvalid                = -7866;                        {  -7866 = The initiator ID is invalid           }
  729.     scsiDataTypeInvalid            = -7865;                        {  -7865 = scsiDataType requested not supported  }
  730.     scsiTransferTypeInvalid        = -7864;                        {  -7864 = scsiTransferType field is too high      }
  731.     scsiCDBLengthInvalid        = -7863;                        {  -7863 = scsiCDBLength field is too big          }
  732.  
  733. { New errors for SCSI Family         }
  734.     scsiUnused74                = -7862;                        {  -7862 =                                           }
  735.     scsiUnused75                = -7861;                        {  -7861 =                                          }
  736.     scsiBadDataLength            = -7860;                        {  -7860 = a zero data length in PB              }
  737.     scsiPartialPrepared            = -7859;                        {  -7859 = could not do full prepare mem for I/O }
  738.     scsiInvalidMsgType            = -7858;                        {  -7858 = Invalid message type (internal)         }
  739.     scsiUnused79                = -7857;                        {  -7857 =                                            }
  740.     scsiBadConnID                = -7856;                        {  -7856 = Bad Connection ID                       }
  741.     scsiUnused81                = -7855;                        {  -7855 =                                          }
  742.     scsiIOInProgress            = -7854;                        {  -7854 = Can't close conn, IO in prog             }
  743.     scsiTargetReserved            = -7853;                        {  -7853 = Target already reserved                 }
  744.     scsiUnused84                = -7852;                        {  -7852 =                                          }
  745.     scsiUnused85                = -7851;                        {  -7851 =                                          }
  746.     scsiBadConnType                = -7850;                        {  -7850 = Bad connection type                     }
  747.     scsiCannotLoadPlugin        = -7849;                        {  -7849 = No matching service category             }
  748.  
  749. { +++ }
  750. {
  751.  * scsiFamilyInternalError and scsiPluginInternalError are intended to handle consistency check failures.
  752.  * For example, if the family stores a record on a lookaside queue, but does not find that record
  753.  * it can use this error to report this failure. SCSI Manager 4.3 uses dsIOCoreErr in a few places,
  754.  * but this is probably not the best error. In general, internal errors should be reported as bugs.
  755.  *
  756.  * The following range of errors is provided for third-party (non-Apple) SCSI SIM and device driver vendors.
  757.  * In general, they would be used for error conditions that are not covered by the standardized errors.
  758.  * They should not normally be conveyed to normal applications, but might be used for communication between
  759.  * a plug-in and a vendor-provided device driver (for example, to manage RAID hot-swapping).
  760.  *
  761.  * Note: I don't know how many SCSI errors are reserved in the error code architecture. Don't assume that
  762.  * we'll actually get sixteen, but we should reserve at least one.
  763.  }
  764.     scsiFamilyInternalError        = -7849;                        {  -7849 = Internal consistency check failed     }
  765.     scsiPluginInternalError        = -7848;                        {  -7848 = Internal consistency check failed     }
  766.     scsiVendorSpecificErrorBase    = -7808;                        {  ??    = Start of third-party error range         }
  767.     scsiVendorSpecificErrorCount = 16;                            {  Number of third-party errors                     }
  768.  
  769. { --- }
  770.     scsiExecutionErrors            = -7936;
  771.     scsiNotExecutedErrors        = -7888;
  772.     scsiParameterErrors            = -7872;
  773.  
  774. { Defines for the scsiResultFlags field }
  775.     scsiSIMQFrozen                = $0001;                        {  The SIM queue is frozen w/this err             }
  776.     scsiAutosenseValid            = $0002;                        {  Autosense data valid for target               }
  777.     scsiBusNotFree                = $0004;                        {  At time of callback, SCSI bus is not free     }
  778.  
  779. { Defines for the bit numbers of the scsiFlags field in the PB header for the SCSIExecIO function }
  780.     kbSCSIDisableAutosense        = 29;                            {  Disable auto sense feature                      }
  781.     kbSCSIFlagReservedA            = 28;                            {                                                }
  782.     kbSCSIFlagReserved0            = 27;                            {                                                }
  783.     kbSCSICDBLinked                = 26;                            {  The PB contains a linked CDB                     }
  784.     kbSCSIQEnable                = 25;                            {  Target queue actions are enabled                 }
  785.     kbSCSICDBIsPointer            = 24;                            {  The CDB field contains a pointer                 }
  786.     kbSCSIFlagReserved1            = 23;                            {                                                   }
  787.     kbSCSIInitiateSyncData        = 22;                            {  Attempt Sync data xfer and SDTR                 }
  788.     kbSCSIDisableSyncData        = 21;                            {  Disable sync, go to async                     }
  789.     kbSCSISIMQHead                = 20;                            {  Place PB at the head of SIM Q                 }
  790.     kbSCSISIMQFreeze            = 19;                            {  Return the SIM Q to frozen state                 }
  791.     kbSCSISIMQNoFreeze            = 18;                            {  Disallow SIM Q freezing                         }
  792.     kbSCSIDoDisconnect            = 17;                            {  Definitely do disconnect                         }
  793.     kbSCSIDontDisconnect        = 16;                            {  Definitely don't disconnect                     }
  794.     kbSCSIDataReadyForDMA        = 15;                            {  Data buffer(s) are ready for DMA                 }
  795.     kbSCSIFlagReserved3            = 14;                            {                                                   }
  796.     kbSCSIDataPhysical            = 13;                            {  SG/Buffer data ptrs are physical                 }
  797.     kbSCSISensePhysical            = 12;                            {  Autosense buffer ptr is physical                 }
  798.     kbSCSIFlagReserved5            = 11;                            {                                                   }
  799.     kbSCSIFlagReserved6            = 10;                            {                                                   }
  800.     kbSCSIFlagReserved7            = 9;                            {                                                   }
  801.     kbSCSIFlagReserved8            = 8;                            {                                                   }
  802.     kbSCSIDataBufferValid        = 7;                            {  Data buffer valid                             }
  803.     kbSCSIStatusBufferValid        = 6;                            {  Status buffer valid                              }
  804.     kbSCSIMessageBufferValid    = 5;                            {  Message buffer valid                             }
  805.     kbSCSIFlagReserved9            = 4;                            {                                                }
  806.  
  807. { Defines for the bit masks of the scsiFlags field }
  808.     scsiDirectionMask            = $C0000000;                    {  Data direction mask                         }
  809.     scsiDirectionNone            = $C0000000;                    {  Data direction (11: no data)                 }
  810.     scsiDirectionReserved        = $00000000;                    {  Data direction (00: reserved)             }
  811.     scsiDirectionOut            = $80000000;                    {  Data direction (10: DATA OUT)             }
  812.     scsiDirectionIn                = $40000000;                    {  Data direction (01: DATA IN)                 }
  813.     scsiDisableAutosense        = $20000000;                    {  Disable auto sense feature                 }
  814.     scsiFlagReservedA            = $10000000;                    {                                               }
  815.     scsiFlagReserved0            = $08000000;                    {                                               }
  816.     scsiCDBLinked                = $04000000;                    {  The PB contains a linked CDB                 }
  817.     scsiQEnable                    = $02000000;                    {  Target queue actions are enabled             }
  818.     scsiCDBIsPointer            = $01000000;                    {  The CDB field contains a pointer             }
  819.     scsiFlagReserved1            = $00800000;                    {                                               }
  820.     scsiInitiateSyncData        = $00400000;                    {  Attempt Sync data xfer and SDTR             }
  821.     scsiDisableSyncData            = $00200000;                    {  Disable sync, go to async                 }
  822.     scsiSIMQHead                = $00100000;                    {  Place PB at the head of SIM Q             }
  823.     scsiSIMQFreeze                = $00080000;                    {  Return the SIM Q to frozen state             }
  824.     scsiSIMQNoFreeze            = $00040000;                    {  Disallow SIM Q freezing                     }
  825.     scsiDoDisconnect            = $00020000;                    {  Definitely do disconnect                     }
  826.     scsiDontDisconnect            = $00010000;                    {  Definitely don't disconnect                 }
  827.     scsiDataReadyForDMA            = $00008000;                    {  Data buffer(s) are ready for DMA             }
  828.     scsiFlagReserved3            = $00004000;                    {    }
  829.     scsiDataPhysical            = $00002000;                    {  SG/Buffer data ptrs are physical             }
  830.     scsiSensePhysical            = $00001000;                    {  Autosense buffer ptr is physical             }
  831.     scsiFlagReserved5            = $00000800;                    {                                            }
  832.     scsiFlagReserved6            = $00000400;                    {                                               }
  833.     scsiFlagReserved7            = $00000200;                    {                                               }
  834.     scsiFlagReserved8            = $00000100;                    {                                               }
  835.  
  836. { bit masks for the scsiIOFlags field in SCSIExecIOPB }
  837.     scsiNoParityCheck            = $0002;                        {  disable parity checking                              }
  838.     scsiDisableSelectWAtn        = $0004;                        {  disable select w/Atn                               }
  839.     scsiSavePtrOnDisconnect        = $0008;                        {  do SaveDataPointer upon Disconnect msg              }
  840.     scsiNoBucketIn                = $0010;                        {  don’t bit bucket in during this I/O                  }
  841.     scsiNoBucketOut                = $0020;                        {  don’t bit bucket out during this I/O              }
  842.     scsiDisableWide                = $0040;                        {  disable wide transfer negotiation                  }
  843.     scsiInitiateWide            = $0080;                        {  initiate wide transfer negotiation                  }
  844.     scsiRenegotiateSense        = $0100;                        {  renegotiate sync/wide before issuing autosense      }
  845.     scsiDisableDiscipline        = $0200;                        {  disable parameter checking on SCSIExecIO calls     }
  846.     scsiIOFlagReserved0080        = $0080;                        {                                                    }
  847.     scsiIOFlagReserved8000        = $8000;                        {                                                       }
  848.  
  849. { Defines for the Bus Inquiry PB fields. }
  850. { scsiHBAInquiry field bits }
  851.     scsiBusMDP                    = $80;                            {  Supports Modify Data Pointer message                         }
  852.     scsiBusWide32                = $40;                            {  Supports 32 bit wide SCSI                                 }
  853.     scsiBusWide16                = $20;                            {  Supports 16 bit wide SCSI                                 }
  854.     scsiBusSDTR                    = $10;                            {  Supports Sync Data Transfer Req message                     }
  855.     scsiBusLinkedCDB            = $08;                            {  Supports linked CDBs                                         }
  856.     scsiBusTagQ                    = $02;                            {  Supports tag queue message                                 }
  857.     scsiBusSoftReset            = $01;                            {  Supports soft reset                                         }
  858.  
  859. { Defines for the scsiDataType field }
  860.     scsiDataBuffer                = 0;                            {  single contiguous buffer supplied                   }
  861.     scsiDataTIB                    = 1;                            {  TIB supplied (ptr in scsiDataPtr)                  }
  862.     scsiDataSG                    = 2;                            {  scatter/gather list supplied                       }
  863.     scsiDataIOTable                = 3;                            { #(7/11/95) Prepared by Block Storage               }
  864.  
  865. { scsiDataTypes field bits  }
  866. {    bits 0->15 Apple-defined, 16->30 3rd-party unique, 31 = reserved }
  867.     scsiBusDataTIB                = $02;                            {  TIB supplied (ptr in scsiDataPtr)         }
  868.     scsiBusDataBuffer            = $01;                            {  single contiguous buffer supplied          }
  869.     scsiBusDataSG                = $04;                            {  scatter/gather list supplied              }
  870.     scsiBusDataIOTable            = $08;                            {  (2/6/95) Prepare Memory for IO }
  871.     scsiBusDataReserved            = $80000000;                    {                                             }
  872.  
  873. { scsiScanFlags field bits }
  874.     scsiBusScansDevices            = $80;                            {  Bus scans for and maintains device list             }
  875.     scsiBusScansOnInit            = $40;                            {  Bus scans performed at power-up/reboot             }
  876.     scsiBusLoadsROMDrivers        = $20;                            {  may load ROM drivers to support targets              }
  877.  
  878. { scsiFeatureFlags field bits }
  879.     scsiBusInternalExternalMask    = $000000C0;                    {  bus internal/external mask                     }
  880.     scsiBusInternalExternalUnknown = $00000000;                    {  not known whether bus is inside or outside      }
  881.     scsiBusInternalExternal        = $000000C0;                    {  bus goes inside and outside the box              }
  882.     scsiBusInternal                = $00000080;                    {  bus goes inside the box                          }
  883.     scsiBusExternal                = $00000040;                    {  bus goes outside the box                      }
  884.     scsiBusCacheCoherentDMA        = $00000020;                    {  DMA is cache coherent                          }
  885.     scsiBusOldCallCapable        = $00000010;                    {  SIM is old call capable                          }
  886.     scsiBusDifferential            = $00000004;                    {  Single Ended (0) or Differential (1)          }
  887.     scsiBusFastSCSI                = $00000002;                    {  HBA supports fast SCSI                          }
  888.     scsiBusDMAavailable            = $00000001;                    {  DMA is available                              }
  889.  
  890. { scsiWeirdStuff field bits }
  891.     scsiOddDisconnectUnsafeRead1 = $0001;                        {  Disconnects on odd byte boundries are unsafe with DMA and/or blind reads  }
  892.     scsiOddDisconnectUnsafeWrite1 = $0002;                        {  Disconnects on odd byte boundries are unsafe with DMA and/or blind writes  }
  893.     scsiBusErrorsUnsafe            = $0004;                        {  Non-handshaked delays or disconnects during blind transfers may cause a crash  }
  894.     scsiRequiresHandshake        = $0008;                        {  Non-handshaked delays or disconnects during blind transfers may cause data corruption  }
  895.     scsiTargetDrivenSDTRSafe    = $0010;                        {  Targets which initiate synchronous negotiations are supported  }
  896.     scsiOddCountForPhysicalUnsafe = $0020;                        {  If using physical addrs all counts must be even, and disconnects must be on even boundries  }
  897.     scsiAbortCmdFixed            = $0040;                        {  Set if abort command is fixed to properly make callbacks  }
  898.     scsiMeshACKTimingFixed        = $0080;                        {  Set if bug allowing Mesh to release ACK prematurely is fixed  }
  899.  
  900. { scsiHBAslotType values }
  901.     scsiMotherboardBus            = $00;                            {  A built in Apple supplied bus                      }
  902.     scsiNuBus                    = $01;                            {  A SIM on a NuBus card                              }
  903.     scsiPDSBus                    = $03;                            {     "  on a PDS card                                 }
  904.     scsiPCIBus                    = $04;                            {     "  on a PCI bus card                             }
  905.     scsiPCMCIABus                = $05;                            {     "  on a PCMCIA card                             }
  906.     scsiFireWireBridgeBus        = $06;                            {     "  connected through a FireWire bridge         }
  907.  
  908. { Defines for the scsiDriverFlags field (in SCSIDriverPB) }
  909.     scsiDeviceSensitive            = $0001;                        {  Only driver should access this device                 }
  910.     scsiDeviceNoOldCallAccess    = $0002;                        {  no old call access to this device                      }
  911.  
  912. {  SIMInitInfo PB }
  913. { directions are for SCSIRegisterBus call ( -> parm, <- result)             }
  914.  
  915. TYPE
  916.     SIMInitInfoPtr = ^SIMInitInfo;
  917.     SIMInitInfo = RECORD
  918.         SIMstaticPtr:            Ptr;                                    {  <- alloc. ptr to the SIM's static vars                  }
  919.         staticSize:                LONGINT;                                {  -> num bytes SIM needs for static vars                  }
  920.         SIMInit:                SIMInitUPP;                                {  -> pointer to the SIM init routine                      }
  921.         SIMAction:                SIMActionUPP;                            {  -> pointer to the SIM action routine                  }
  922.         SIM_ISR:                SCSIInterruptUPP;                        {        reserved                                              }
  923.         SIMInterruptPoll:        SCSIInterruptUPP;                        {  -> pointer to the SIM interrupt poll routine             }
  924.         NewOldCall:                SIMActionUPP;                            {  -> pointer to the SIM NewOldCall routine                 }
  925.         ioPBSize:                UInt16;                                    {  -> size of SCSI_IO_PBs required for this SIM             }
  926.         oldCallCapable:            BOOLEAN;                                {  -> true if this SIM can handle old-API calls             }
  927.         simInfoUnused1:            SInt8;                                    {        reserved                                             }
  928.         simInternalUse:            LONGINT;                                {  xx not affected or viewed by XPT                         }
  929.         XPT_ISR:                SCSIUPP;                                {     reserved                                             }
  930.         EnteringSIM:            SCSIUPP;                                {  <- ptr to the EnteringSIM routine                     }
  931.         ExitingSIM:                SCSIUPP;                                {  <- ptr to the ExitingSIM routine                         }
  932.         MakeCallback:            SCSIMakeCallbackUPP;                    {  <- the XPT layer’s SCSIMakeCallback routine             }
  933.         busID:                    UInt16;                                    {  <- bus number for the registered bus                     }
  934.         simSlotNumber:            SInt8;                                    {  <- Magic cookie to place in scsiHBASlotNumber (PCI)     }
  935.         simSRsrcID:                SInt8;                                    {  <- Magic cookie to place in scsiSIMsRsrcID     (PCI)     }
  936.         simRegEntry:            Ptr;                                    {  -> The SIM's RegEntryIDPtr                     (PCI)     }
  937.     END;
  938.  
  939. { Glue between SCSI calls and SCSITrap format }
  940.  
  941. CONST
  942.     xptSCSIAction                = $0001;
  943.     xptSCSIRegisterBus            = $0002;
  944.     xptSCSIDeregisterBus        = $0003;
  945.     xptSCSIReregisterBus        = $0004;
  946.     xptSCSIKillXPT                = $0005;                        {  kills Mini-XPT after transition  }
  947.     xptSCSIInitialize            = $000A;                        {  Initialize the SCSI manager  }
  948.  
  949. {
  950.  * SCSI bus status. These values are returned by the SCSI target in the status phase.
  951.  * They are not related to Macintosh status values (except that values other than
  952.  * scsiStatusGood will result in scsiResult set to scsiNonZeroStatus).
  953.  }
  954.     scsiStatGood                = $00;                            {  Good Status }
  955.     scsiStatCheckCondition        = $02;                            {  Check Condition }
  956.     scsiStatConditionMet        = $04;                            {  Condition Met }
  957.     scsiStatBusy                = $08;                            {  Busy }
  958.     scsiStatIntermediate        = $10;                            {  Intermediate }
  959.     scsiStatIntermedMet            = $14;                            {  Intermediate - Condition Met }
  960.     scsiStatResvConflict        = $18;                            {  Reservation conflict }
  961.     scsiStatTerminated            = $22;                            {  Command terminated }
  962.     scsiStatQFull                = $28;                            {  Queue full }
  963.  
  964. {  SCSI messages }
  965.     kCmdCompleteMsg                = 0;
  966.     kExtendedMsg                = 1;                            {  0x01 }
  967.     kSaveDataPointerMsg            = 2;                            {  0x02 }
  968.     kRestorePointersMsg            = 3;                            {  0x03 }
  969.     kDisconnectMsg                = 4;                            {  0x04 }
  970.     kInitiatorDetectedErrorMsg    = 5;                            {  0x05 }
  971.     kAbortMsg                    = 6;                            {  0x06 }
  972.     kMsgRejectMsg                = 7;                            {  0x07 }
  973.     kNoOperationMsg                = 8;                            {  0x08 }
  974.     kMsgParityErrorMsg            = 9;                            {  0x09 }
  975.     kLinkedCmdCompleteMsg        = 10;                            {  0x0a }
  976.     kLinkedCmdCompleteWithFlagMsg = 11;                            {  0x0b }
  977.     kBusDeviceResetMsg            = 12;                            {  0x0c }
  978.     kAbortTagMsg                = 13;                            {  0x0d }
  979.     kClearQueueMsg                = 14;                            {  0x0e }
  980.     kInitiateRecoveryMsg        = 15;                            {  0x0f }
  981.     kReleaseRecoveryMsg            = 16;                            {  0x10 }
  982.     kTerminateIOProcessMsg        = 17;                            {  0x11 }
  983.     kSimpleQueueTag                = $20;                            {  0x20 }
  984.     kHeadOfQueueTagMsg            = $21;                            {  0x21 }
  985.     kOrderedQueueTagMsg            = $22;                            {  0x22 }
  986.     kIgnoreWideResidueMsg        = $23;                            {  0x23 }
  987.  
  988.  
  989. { moveq #kSCSIx, D0;  _SCSIAtomic }
  990. FUNCTION SCSIAction(VAR parameterBlock: SCSI_PB): OSErr;
  991.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  992.     INLINE $205F, $7001, $A089, $3E80;
  993.     {$ENDC}
  994. FUNCTION SCSIRegisterBus(VAR parameterBlock: SIMInitInfo): OSErr;
  995.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  996.     INLINE $205F, $7002, $A089, $3E80;
  997.     {$ENDC}
  998. FUNCTION SCSIDeregisterBus(VAR parameterBlock: SCSI_PB): OSErr;
  999.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1000.     INLINE $205F, $7003, $A089, $3E80;
  1001.     {$ENDC}
  1002. FUNCTION SCSIReregisterBus(VAR parameterBlock: SIMInitInfo): OSErr;
  1003.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1004.     INLINE $205F, $7004, $A089, $3E80;
  1005.     {$ENDC}
  1006. FUNCTION SCSIKillXPT(VAR parameterBlock: SIMInitInfo): OSErr;
  1007.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1008.     INLINE $205F, $7005, $A089, $3E80;
  1009.     {$ENDC}
  1010.  
  1011. {$ALIGN RESET}
  1012. {$POP}
  1013.  
  1014. {$SETC UsingIncludes := SCSIIncludes}
  1015.  
  1016. {$ENDC} {__SCSI__}
  1017.  
  1018. {$IFC NOT UsingIncludes}
  1019.  END.
  1020. {$ENDC}
  1021.